package cn.iocoder.yudao.module.worker.dal.mysql.clerkapply;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.worker.controller.app.clerkapply.vo.AppClerkApplyPageReqVO;
import cn.iocoder.yudao.module.worker.dal.dataobject.clerkapply.ClerkApplyDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.worker.controller.admin.clerkapply.vo.*;

/**
 * 店员申请 Mapper
 *
 * @author Jerry
 */
@Mapper
public interface ClerkApplyMapper extends BaseMapperX<ClerkApplyDO> {

    default PageResult<ClerkApplyDO> selectPage(ClerkApplyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClerkApplyDO>()
                .eqIfPresent(ClerkApplyDO::getWorkerClerkId, reqVO.getWorkerClerkId())
                .eqIfPresent(ClerkApplyDO::getUserId, reqVO.getUserId())
                .likeIfPresent(ClerkApplyDO::getNickname, reqVO.getNickname())
                .eqIfPresent(ClerkApplyDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(ClerkApplyDO::getSex, reqVO.getSex())
                .eqIfPresent(ClerkApplyDO::getAge, reqVO.getAge())
                .eqIfPresent(ClerkApplyDO::getWeixin, reqVO.getWeixin())
                .eqIfPresent(ClerkApplyDO::getMobile, reqVO.getMobile())
                .eqIfPresent(ClerkApplyDO::getCity, reqVO.getCity())
                .eqIfPresent(ClerkApplyDO::getExperience, reqVO.getExperience())
                .eqIfPresent(ClerkApplyDO::getSound, reqVO.getSound())
                .eqIfPresent(ClerkApplyDO::getSoundType, reqVO.getSoundType())
                .betweenIfPresent(ClerkApplyDO::getSoundTime, reqVO.getSoundTime())
                .eqIfPresent(ClerkApplyDO::getAlbums, reqVO.getAlbums())
                .eqIfPresent(ClerkApplyDO::getIntro, reqVO.getIntro())
                .eqIfPresent(ClerkApplyDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ClerkApplyDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ClerkApplyDO::getId));
    }

    default PageResult<ClerkApplyDO> selectPage(AppClerkApplyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClerkApplyDO>()
                .eqIfPresent(ClerkApplyDO::getWorkerClerkId, reqVO.getWorkerClerkId())
                .eqIfPresent(ClerkApplyDO::getUserId, reqVO.getUserId())
                .likeIfPresent(ClerkApplyDO::getNickname, reqVO.getNickname())
                .eqIfPresent(ClerkApplyDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(ClerkApplyDO::getSex, reqVO.getSex())
                .eqIfPresent(ClerkApplyDO::getAge, reqVO.getAge())
                .eqIfPresent(ClerkApplyDO::getWeixin, reqVO.getWeixin())
                .eqIfPresent(ClerkApplyDO::getMobile, reqVO.getMobile())
                .eqIfPresent(ClerkApplyDO::getCity, reqVO.getCity())
                .eqIfPresent(ClerkApplyDO::getExperience, reqVO.getExperience())
                .eqIfPresent(ClerkApplyDO::getSound, reqVO.getSound())
                .eqIfPresent(ClerkApplyDO::getSoundType, reqVO.getSoundType())
                .betweenIfPresent(ClerkApplyDO::getSoundTime, reqVO.getSoundTime())
                .eqIfPresent(ClerkApplyDO::getAlbums, reqVO.getAlbums())
                .eqIfPresent(ClerkApplyDO::getIntro, reqVO.getIntro())
                .eqIfPresent(ClerkApplyDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ClerkApplyDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ClerkApplyDO::getId));
    }

    default ClerkApplyDO getClerkApply(Long userId, Long id){
        return selectOne(new LambdaQueryWrapperX<ClerkApplyDO>()
                .eqIfPresent(ClerkApplyDO::getUserId, userId)
                .eq(ClerkApplyDO::getId, id));
    }

    default List<ClerkApplyDO> getClerkApplyList(Long userId){
        return selectList(new LambdaQueryWrapperX<ClerkApplyDO>()
                .eq(ClerkApplyDO::getUserId, userId)
                .eq(ClerkApplyDO::getStatus, false));
    }
}